package com.hmy.contract.controller;

import com.hmy.ccp.common.result.JsonResult;
import com.hmy.ccp.error.annotations.HmyGateWayController;
import com.hmy.contract.bo.request.contractProcess.ContractProcessApprovalRequest;
import com.hmy.contract.bo.request.contractProcess.ContractProcessRejectRequest;
import com.hmy.contract.bo.response.contractProcess.ContractProcessApprovalResponse;
import com.hmy.contract.bo.response.contractProcess.ContractProcessRejectResponse;
import com.hmy.contract.service.contract.IContractProcessService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Description 合同管理流程管理
 * @Author seven.qi
 * @Date 2023/12/19 19:32
 * @Version 1.0
 */

@RestController
@RequestMapping("/api/contractProcess")
@Api(tags = "合同流程管理")
@Validated
@Slf4j
@HmyGateWayController
public class ContractProcessController {


    @Resource
    private IContractProcessService contractProcessService;

    /**
     * 通过
     *
     * @param contractProcessApprovalRequest 通过入参
     * @return {@link ContractProcessApprovalResponse}
     */
    @PostMapping("approval")
    @ApiOperation("通过")
    public JsonResult<ContractProcessApprovalResponse> approval(@RequestBody ContractProcessApprovalRequest contractProcessApprovalRequest) {
        return JsonResult.success(contractProcessService.approval(contractProcessApprovalRequest));
    }

    /**
     * 拒绝
     *
     * @param contractProcessRejectRequest 拒绝入参
     * @return {@link ContractProcessRejectResponse}
     */
    @PostMapping("reject")
    @ApiOperation("拒绝")
    public JsonResult<ContractProcessRejectResponse> reject(@RequestBody ContractProcessRejectRequest contractProcessRejectRequest) {
        return JsonResult.success(contractProcessService.reject(contractProcessRejectRequest));
    }
}
